#include "DrvUART.h"
#include "DrvGPIO.h"

/** Define the delay count */
#define DELAYCOUNT 5000

/*************************************************************************//**
 * @brief   UART Print example
 * @param	None
 * @return	None
*****************************************************************************/
void UartPrintExp()
{
	STR_UART_T       UartParam;
	E_DRVGPIO_FUNC   FuncNum = E_FUNC_UART0;
	E_UART_PORT      UartNum = UART_PORT0;

	/* Enable External 12 MHz Crystal Oscillator */
	UNLOCKREG();
	SYSCLK->PWRCON.XTL12M_EN = 1;

	/* Waiting for 12M Xtal stalble */
    SysTick->LOAD = DELAYCOUNT * 22; /* Assume the internal 22MHz RC used */
    SysTick->VAL   =  (0x00);
    SysTick->CTRL = (1 << 2) | (1);
    /* Waiting for down-count to zero */
    while((SysTick->CTRL & (1 << 16)) == 0);

	/* UART initial function */
	DrvGPIO_InitFunction(FuncNum);

	UartParam.u32BaudRate        = 115200;
	UartParam.u8cDataBits        = DRVUART_DATABITS_8;
	UartParam.u8cStopBits        = DRVUART_STOPBITS_1;
	UartParam.u8cParity          = DRVUART_PARITY_NONE;
	UartParam.u8cRxTriggerLevel  = DRVUART_FIFO_1BYTES;
	UartParam.u8TimeOut        	 = 0;

	/* Open the UART */
	DrvUART_Open(UartNum, &UartParam);

	/* Write data to the UART */
	DrvUART_Write(UartNum,  (uint8_t *)"Hello Word !", sizeof("Hello Word !")-1);
}